// 魔王语言 goodnotes P103 书本 P96
#include <iostream>
#include <string>
#define STACK_INIT_SIZE 100;
#define STACK_INCREMENT 10;
using namespace std;
string satan_quote;
string explained;
typedef struct
{
    char *base;
    char *top;
    char c;
    long long stacksize;
} SqStack;

string character_map[127];

int InitStack(SqStack &S)
{
    S.base = (string *)malloc(STACK_INIT_SIZE * sizeof(string));
    if (!S.base)
        exit(OVERFLOW);
    S.top = S.base;
    S.stacksize = STACK_INIT_SIZE;
    return 1;
}

void GetTop(SqStack S, char &e)
{
    if (S.top == S.base)
        exit;
    e = *(S.top - 1);
    return 1;
}

void Push(SqStack &S, char e)
{
    if (S.top - S.base >= S.stacksize)
    {
        S.base = (char *)realloc(S.base, (S.stacksize + STACK_INCREMENT) * sizeof(string));
        if (!S.base)
            exit(OVERFLOW);
        S.top = S.base + S.stacksize;
        S.stacksize += STACK_INCREMENT;
    }
    *S.top++ = e;
}

char Pop(SqStack &S)
{
    if (S.top == S.base)
        exit;
    return *--S.top;
}

int Empty(SqStack &S)
{
    if (S.top == S.base)
    {
        return 1;
    }
    return 0;
}

void InitMap()
{
    character_map['t'] = "天";
    character_map['d'] = "地";
    character_map['s'] = "上";
    character_map['a'] = "一只";
    character_map['e'] = "鹅";
    character_map['z'] = "追";
    character_map['g'] = "赶";
    character_map['x'] = "下";
    character_map['n'] = "蛋";
    character_map['h'] = "恨";
}

void SpeakHumanly(string &satan_quote)
{
    for (int i; i < satan_quote.length(); i++)
    {
        cout << character_map[satan_quote[i]];
    }
}

int deal_with_bracket(int pos, SqStack &brac)
{
    pos++;
    char gang = satan_quote[pos];
    pos++;
    while (satan_quote[pos] != ')')
    {
        Push(brac, gang);
        if (satan_quote[pos] == '(')
        {
            pos = deal_with_bracket(pos, brac) + 1;
        }
        else
        {
            Push(brac, satan_quote[pos]);
            pos++;
        }
    }
    Push(brac, gang);
    return pos;
}



int main()
{
    SqStack brac;
    InitMap();
    InitStack(brac);
    cout << "Enter Satan's quote." << endl;
    cin >> satan_quote;
    for (int i = 0; i < satan_quote.length(); i++)
    {
        if (satan_quote[i] != '(')
        {

        }
        else
        {
            deal_with_bracket(i, brac);
        }
    }
    SpeakHumanly(explained);
}